package Leason3;

import java.util.Arrays;
import java.util.Scanner;

public class Task7 {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int numbers;
		
		System.out.println("Enter the length of the first array");
		int size = sc.nextInt();
		int[] first = new int[size];
		int[] second = new int[size];		
		
			System.out.println("Enter the numbers of first array elements");
		
		for(int i = 0; i < first.length; i++)
		{
			System.out.println("Element " + i +":");
			
			numbers = sc.nextInt();
			first[i] = numbers;
		}
		
		int a = 0;
		int b = 0;
		
		int n = 0;
		int m = 1;
		
		int x = first[n];
		int y = first[m];
		
		for (int i = 0; i < first.length; i++)
		{
			b=y;
			
			second[i] = a+b;
			
			a = x;
			n++;
			m++;
			
			if (m == size)
			{
				y=0;
				m=0;
				n=0;
			}
			else
			{
			y = first[m];
			x = first[n];
			}
		}
		
		System.out.println("The second array is: " + Arrays.toString(second));
		
		
	}

}
